package com.theaf.basemodule.common.model;

import com.theaf.core.annotation.FieldCn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @Author:songwenke
 * @Description: 用户
 * @Date:create in 14:49 2017/12/21
 * @Modified By:
 **/
@Entity
@Table(name = "sys_user")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysUser {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "user_id_req")
    @SequenceGenerator(name = "user_id_req", sequenceName = "sys_req")
    private Long id;

    @Column(name = "user_name",unique=true,nullable = false)
    @FieldCn(value = "账号")
    private String userName;

    @Column(name = "cname",nullable = false)
    @FieldCn(value = "姓名")
    private String cname;

    @Column(name = "mobile",nullable = false)
    @FieldCn(value = "手机")
    private String mobile;

    @Column(name = "mail")
    @FieldCn(value = "邮箱")
    private String mail;

    @Column(name = "wx_id")
    @FieldCn(value = "企业微信ID")
    private String wxId;

    @Column(name = "pass",nullable = false)
    @FieldCn(value = "密码")
    private String pass;

    @Column(name = "pass_ak",nullable = false)
    @FieldCn(value = "密钥")
    private String passAk;

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="org_id")
    private SysOrg sysOrg;

    @Column(name = "repeated")
    @FieldCn(value = "是否可重复登录")
    private boolean repeated;

    @Column(name = "limit_ip")
    @FieldCn(value = "限制IP")
    private String limitIp;

    /**
     * 1增2修3删
     */
    @Column(name = "state")
    @FieldCn(value = "状态")
    private int state=1;

    @Column(name = "enable")
    @FieldCn(value = "是否启用")
    private Boolean enable=true;

    @Column(name = "creater")
    @FieldCn(value = "创建者")
    private Long creater;

    @Column(name = "create_time")
    @FieldCn(value = "创建时间")
    private Date createTime;

    @Column(name = "updater")
    @FieldCn(value = "修改者")
    private Long updater;

    @Column(name = "update_time")
    @FieldCn(value = "修改时间")
    private Date updateTime;

    @Column(name = "order_no")
    @FieldCn(value = "排序号")
    private int orderNo;

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="pos_id")
    private SysPosition position;

    @OneToMany(cascade={CascadeType.ALL})
    @JoinColumn(name="use_id")
    private List<SysUseAuth> sysUseAuths;

    @OneToMany(cascade={CascadeType.ALL})
    @JoinColumn(name="use_id")
    private List<SysUserRange> sysUserRanges;
}
